package net.yla.smartbus.core.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Date: 2020-09-21 15:11
 * @Author: Being Nobody
 * @Version: 1.0
 * 设置虚拟路径，访问绝对路径下资源
 */
@Configuration
public class WebResourceConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // addResourceLocations指的是文件放置的目录，addResoureHandler指的是对外暴露的访问路径
        // 映射项目资源路径 classpath: target/classes包下
        registry.addResourceHandler("/images/**").addResourceLocations("classpath:/images/");
        // 映射本地资源路径 file: 本地文件放置的路径下
        registry.addResourceHandler("/static/picture/**").addResourceLocations("file:F:/static/picture/");
    }
}
